import turtle
import math

def draw_circle(radius, color, x=0, y=0):
    """绘制一个指定半径、颜色和位置的圆"""
    turtle.penup()
    turtle.goto(x, y - radius)  # 移动到圆的底部
    turtle.pendown()
    turtle.fillcolor(color)
    turtle.begin_fill()
    turtle.circle(radius)
    turtle.end_fill()

def draw_triangle(size, color, x=0, y=0):
    """绘制一个指定大小、颜色和位置的三角形（耳朵）"""
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.fillcolor(color)
    turtle.begin_fill()
    for _ in range(3):
        turtle.forward(size)
        turtle.left(120)
    turtle.end_fill()

def draw_whiskers(x, y):
    """绘制猫咪的胡须"""
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.pensize(2)
    # 左边胡须
    for angle in [-10, 0, 10]:
        turtle.setheading(angle)
        turtle.forward(40)
        turtle.backward(40)
    # 右边胡须
    turtle.penup()
    turtle.goto(x + 30, y)  # 向右移动到另一边
    turtle.pendown()
    for angle in [180+10, 180, 180-10]:
        turtle.setheading(angle)
        turtle.forward(40)
        turtle.backward(40)
    turtle.pensize(1)

def draw_cat():
    """绘制一只完整的小猫咪"""
    # 设置画布
    turtle.setup(width=600, height=600)
    turtle.title("可爱的小猫咪")
    turtle.speed(3)  # 绘制速度：1-10，10最快
    turtle.bgcolor("#f0f0f0")  # 浅灰色背景
    
    # 绘制猫的头部
    draw_circle(100, "#f8d7da", 0, -50)  # 浅粉色头部
    
    # 绘制耳朵
    turtle.setheading(60)
    draw_triangle(60, "#f8d7da", -60, 50)  # 左耳朵
    draw_triangle(60, "#f8d7da", 60, 50)   # 右耳朵
    
    # 耳朵内部（粉红色）
    turtle.setheading(60)
    draw_triangle(30, "#f1b0b7", -50, 70)  # 左耳朵内部
    draw_triangle(30, "#f1b0b7", 50, 70)   # 右耳朵内部
    
    # 绘制眼睛
    draw_circle(15, "white", -35, 20)  # 左眼白
    draw_circle(15, "white", 35, 20)   # 右眼白
    draw_circle(8, "black", -38, 25)   # 左瞳孔
    draw_circle(8, "black", 32, 25)    # 右瞳孔
    draw_circle(3, "white", -33, 30)   # 左眼高光
    draw_circle(3, "white", 37, 30)    # 右眼高光
    
    # 绘制鼻子
    turtle.penup()
    turtle.goto(0, 0)
    turtle.pendown()
    turtle.fillcolor("#f1b0b7")
    turtle.begin_fill()
    turtle.setheading(30)
    turtle.forward(15)
    turtle.setheading(150)
    turtle.forward(15)
    turtle.setheading(270)
    turtle.forward(15)
    turtle.end_fill()
    
    # 绘制嘴巴
    turtle.penup()
    turtle.goto(0, -15)
    turtle.pendown()
    turtle.setheading(270)
    turtle.forward(10)
    turtle.setheading(225)
    turtle.forward(15)
    turtle.penup()
    turtle.goto(0, -25)
    turtle.pendown()
    turtle.setheading(315)
    turtle.forward(15)
    
    # 绘制胡须
    draw_whiskers(-15, -5)
    
    # 绘制脸颊红晕
    draw_circle(15, "#f1b0b7", -60, -10)  # 左脸颊
    draw_circle(15, "#f1b0b7", 60, -10)   # 右脸颊
    
    # 完成绘制
    turtle.hideturtle()
    turtle.done()

if __name__ == "__main__":
    draw_cat()
    
    